import { lazy } from 'react'
import { Navigate, createBrowserRouter } from "react-router-dom";

import App from '../App'

const MyApp = lazy(() => import('../views/MyApp'))
const Home = lazy(() => import('../views/Home'))
const Cate = lazy(() => import('../views/Cate'))
const Mess = lazy(() => import('../views/Mess'))
const Order = lazy(() => import('../views/Order'))
const My = lazy(() => import('../views/My'))
const Login = lazy(() => import('../views/Login'))
const NotFound = lazy(() => import('../views/NotFound'))

const Take = lazy(() => import('../views/Mess/Take'))
const DoorOrder = lazy(() => import('../views/Home/DoorOrder'))
const FreeFood = lazy(() => import('../views/Cate/FreeFood'))
const Money = lazy(() => import('../views/My/Money'))
const DuanWei = lazy(() => import('../views/My/DuanWei'))


export const routes = [
    {
        path: '/',
        element: <App />,
        children: [
            {
                index: true,
                element: <Navigate to='/myapp' />
            },
            {
                path: 'home',
                element: <Home />,
            },
            {
                path: 'doorOrder',
                element: <DoorOrder />,
            },
            {
                path: 'cate',
                element: <Cate />
            },
            {
                path: 'freeFood',
                element: <FreeFood />,
            },
            {
                path: 'mess',
                element: <Mess />,
            },
            {
                path: 'order',
                element: <Order />
            },
            {
                path: 'my',
                element: <My />
            },
            {
                path: 'money',
                element: <Money />
            },
            {
                path: 'duanwei',
                element: <DuanWei />
            },
            {
                path: 'login',
                element: <Login />
            },
            {
                path: 'task',
                element: <Take />
            },
            {
                path: '*',
                element: <NotFound />,
            }
        ]
    },
    {
        path: 'myapp',
        element: <MyApp />
    }
];

const router = createBrowserRouter(routes);

export default router;